package com.ghsc.ghxc.jsb.ui.message.view.gif

import androidx.appcompat.app.AppCompatActivity
import com.ghsc.ghxc.jsb.R
import com.ghsc.ghxc.jsb.ui.live.bean.CustImNoticeBean
import com.ghsc.ghxc.jsb.ui.live.view.gif.GiftFragment
import com.lxj.xpopup.core.BottomPopupView

/**
 * 项目：GuoHuaMall
 * 包名：com.ghsc.ghxc.ui.live.view.gif
 * 类名：GiftPopup
 * 创建时间：2023/9/14 22:31
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 */
class ImGiftPopup (context: AppCompatActivity, account: String): BottomPopupView(context) {

    private val mContext = context
    private val accountId=account

    private var giveGiftResult:((id:Int,count:Int,isBackpack:Boolean) -> Unit)? = null

    override fun getImplLayoutId() = R.layout.popup_gift

    override fun onCreate() {
        super.onCreate()
        val beginTransaction = mContext.supportFragmentManager.beginTransaction()
        val giftFragment = ImGiftFragment.newInstance(accountId)
        beginTransaction.add(R.id.flContainer,giftFragment)
        beginTransaction.commit()
        giftFragment.setOnGiveGiftResultListener { id, count,isBackpack ->
            giveGiftResult?.invoke(id, count,isBackpack)
        }
        giftFragment.setOnDismissListener {
            this@ImGiftPopup.dismiss()
        }
    }

    override fun getInternalFragmentNames(): MutableList<String> {
        val list = mutableListOf<String>()
        list.add(ImGiftFragment::class.java.simpleName)
        return list
    }

    override fun getMaxWidth() = 0

    fun setOnGiveGiftResultListener(listener: ((id:Int,count:Int,isBackpack:Boolean) -> Unit)){
        this.giveGiftResult = listener
    }

}
